$(document).ready(function() {
  var confQuotePadding = '.7em';
  
  // Comments are not sorted because then it would require to deal with other pages. Just modifying all sub-comments (level > 0) on the current page:
  $('.sub-comment').each(function() {
    
    var commentText = $(this).find('.comm-text:first');
    var parentIndent = $(this).parents('.indented:first');
    var parentComment = parentIndent.prevAll('.first-comment, .sub-comment').first();
    
    /* DUMMY: we have to set this css property here (see "style.css") */
    parentIndent.css('margin-left', 0);
    
    // Not all errors are tracked... The parent comment was found:
    if (parentComment.length) {
      // Adding the quote block with the author name before the beginning of the text of current comment.
      /* DUMMY: we have to set padding here (see "style.css") */
      commentText.prepend('<div class="bc-quote" style="padding: ' + confQuotePadding + '"><span class="bc-user">' + parentComment.find('.username:first').find('a:first').text() + '</span> | </div>');
      var thisQuote = commentText.children(':first');  // the new quote is exactly here
      
      // Adding the date and the text of the quote (after the author).
      thisQuote.append(parentComment.find('.comment_date:first').clone());  // cloning the whole div
      thisQuote.append('<br />');  // even if the text will not be "<p>..." it must begin with the new line
      thisQuote.append(parentComment.find('.comm-text:first').children(':not(.bc-quote)').clone());  // cloning the contents of the div
    }
    // The parent was NOT found:
    else {
      /* DUMMY: we have to set padding here (see "style.css") */
      commentText.prepend('<div class="bc-quote bc-error" style="padding: ' + confQuotePadding + '">The quote is not accessible because it\'s displayed on the other page.</div>');
    }
    
  });
});
